#include <stdio.h>

/**
 * 选择第几个元素
 */
void insert(int *arr, int n)
{
    int key = arr[n];
    int i = n;
    while (arr[i - 1] > key)
    {
        arr[i] = arr[i - 1];
        --i;
        if (i == 0)
        {
            break;
        }
    }
    arr[i] = key;
}

int main()
{
    int arr[] = {
        3,
        7,
        4,
        2,
        6,
        1,
    };
    for (int i = 1; i < 6; i++)
    {
        insert(arr, i);
    }

    for (int i = 0; i < 6; i++)
    {
        printf("%d ", arr[i]);
    }
    return 0;
}